﻿
let divUL = document.querySelector(".divUL");



let Tool = document.querySelector(".Tool");
let LeftNav = document.querySelector(".LeftNav");
let right_content = document.querySelector(".right_content");
Tool.onclick = function () {
    if (Tool.classList.contains("active")) {
        Tool.classList.remove("active");

        LeftNav.classList.remove("active");
        right_content.style.width = "calc(100% - 250px)";
    } else {
        LeftNav.classList.add("active");

        Tool.classList.add("active");
        right_content.style.width = "100%";

    }
}
let User_info = document.querySelector(".User_info");
let dropdown_menu = document.querySelector(".dropdown_menu");
User_info.onclick = function () {
    if (dropdown_menu.style.display == "none") {
        dropdown_menu.style.display = "block";

    } else {
        dropdown_menu.style.display = "none";
    }
}



$.get("/Home/getMenu").then((res) => {







    res.data.forEach((item, i) => {
        let Li = document.createElement("div");
        Li.className = "Li";

        let line = document.createElement("div");
        line.className = "line";

        let leftKuai = document.createElement("div");
        leftKuai.className = "leftKuai";


        let star = document.createElement("div");
        star.className = "star";


        let star_i = document.createElement("i");
        star_i.className = "fas fa-home";
        star.appendChild(star_i);

        let a = document.createElement("a");
        a.innerHTML = item.name;

        let left_i = document.createElement("i");
        left_i.className = "fas fa-caret-right Left";



        Li.appendChild(line);
        Li.appendChild(leftKuai);
        Li.appendChild(star);
        Li.appendChild(a);
        Li.appendChild(left_i);
        divUL.appendChild(Li);


        let ChildNode = document.createElement("div");
        ChildNode.className = "ChildNode";

        Li.onclick = function () {





            if (Li.classList.contains("active")) {
                Li.classList.remove("active");
                ChildNode.style.height = `0px`;


            } else {

                let allLi = document.querySelectorAll(".divUL .Li");
                allLi.forEach((item) => {
                    item.classList.remove("active");
                });

                let allChildNode = document.querySelectorAll(".divUL .ChildNode");
                allChildNode.forEach((item) => {
                    item.style.height = `0px`;

                });



                Li.classList.add("active");
                ChildNode.style.height = `${item.ChildMenu.length * 45}px`;
            }
        }


        item.ChildMenu.forEach((o, e) => {
            let ChildOption = document.createElement("div");
            ChildOption.className = "ChildOption";
            let Xian = document.createElement("div");
            Xian.className = "Xian";
            let link = document.createElement("a");
            link.innerHTML = o.name;

            ChildOption.appendChild(Xian);
            ChildOption.appendChild(link);
            ChildNode.appendChild(ChildOption);


            ChildOption.onclick = function () {
                let allchild = document.querySelectorAll(".ChildNode .ChildOption");
                allchild.forEach((item) => {
                    item.classList.remove("active");
                });

                ChildOption.classList.add("active");

                window.location.href = o.url;
            }


        });

        divUL.appendChild(ChildNode);

    });

    let index_Loading = divUL.querySelector(".index_Loading");
    index_Loading.remove();
});
